﻿@using KMF.Utility
@using KMF.WebUI.CustomHelpers
@model IEnumerable<KMF.Common.ProductPromotionTopListDto>
@if (Model.Any())
{
    <div class="bb_product_most bb_p_m_paddTop">
        <div class="bb_p_m_header">
            <span class="babo-icon-list bb_p_m_title_km clearfix">
                <span class="bb_p_m_txt1">SẢN PHẨM<br />
                </span>
                <span class="bb_p_m_txt2">KHUYẾN MẠI</span>
                <span class="bb_all">
                    <span class="bb_p_m_txt3 ">                        
                        <a href="@Url.Action("Index","Promotion")" class="babo-icon-list lnktitleList">XEM THÊM</a>
                    </span>
                </span>
            </span>
        </div>
        <div class="bb_p_m_body">
            <ul class="bb_product_list">
                @foreach (var item in Model)
                {
                    var pDetailLink = Url.Action("Index", "ProductDetail", new { productId = item.Id, productName = StringUtil.RemoveSpecialCharactersVn(item.Name) });
                    //var pDetailLink = "javascript:void(0);";
                    var productStatus = string.Empty;
                    switch (item.ProductStatus)
                    {
                        case "conhang":
                            productStatus = "CÒN HÀNG"; break;
                        case "hethang":
                            productStatus = "HẾT HÀNG";
                            break;
                        case "goihang":
                            productStatus = "GỌI HÀNG";
                            break;
                        default:
                            productStatus = "CÒN HÀNG";
                            break;
                    }
                    decimal rootPrice = item.Price;
                    decimal price = rootPrice;
                    if (item.PromotionPercent > 0)
                    {
                        price = rootPrice - (rootPrice * item.PromotionPercent) / 100;
                    }
                    else if (item.DecreasePrice > 0)
                    {
                        price = rootPrice - item.DecreasePrice;
                    }
                    <li class="bb_p_item_margin">
                        <div class="bb_p_item">
                            <a href="@pDetailLink" class="bb_lnk_name">
                                <div class="bb_p_img">
                                    <img src="@item.ImagePath.ImagePathThumb(168,168)" width="168" height="168" alt="@item.Name" class="img-loading"/>
                                </div>
                                <div class="bb_p_name">
                                    <h5>@StringUtil.LimitLength(item.Name, 60, "...")</h5>
                                    <span class="bb_p_name_txt1"></span><br />
                                    <span class="bb_p_name_txt2">@item.ProviderName</span>
                                </div>
                                <div class="bb_p_price">
                                    <span class="bb_p_priceCurrent">
                                        @price.ToString("#,###") <span class="bb_p_normal_txt">VNĐ</span>
                                        @*<i class="babo-icon-special bb_p_icon_buy" title="Số lượt thanh toán"></i>*@
                                    </span>
                                    <span class="bb_p_priceOld">
                                        <span class="bb_p_priOld_left">
                                            @rootPrice.ToString("#,###") VNĐ
                                        </span>
                                        <span class="bb_p_cusBuy"></span>
                                        <span class="clr"></span>
                                    </span>
                                    <div class="bb_p_promotion_percent">-@item.PromotionPercent%</div>
                                </div>
                            </a>
                        
                        </div>
                    </li>
                }
            </ul>
        </div>
    </div>
}
